package cn.song.entity.easyexcel;

import cn.song.annotation.EasyExcel;
import cn.song.config.convert.BaseEnumTypeConverter;
import cn.song.config.convert.EasyExcelEnumConverter;
import cn.song.constants.enums.GenderEnum;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 测试EasyExcel
 *
 * @author SongRenShuo
 * @date 2025/01/05
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
// @Accessors(chain = true) //与EasyExcel冲突 会读取不到值
@ExcelIgnoreUnannotated
public class ExcelModel{
    @ExcelProperty(value = "序号", index = 0)
    private String id;
    @ExcelProperty(value = "姓名", index = 1)
    private String name;
    @ExcelProperty(value = "生日", index = 2)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ColumnWidth(16)
    private Date birthday;
    @ExcelProperty(value = "年龄", index = 3)
    private Integer age;
    @ExcelProperty(value = "性别", index = 4,converter = BaseEnumTypeConverter.class)
    private GenderEnum gender;
    @ExcelProperty(value = "性别02", index = 5,converter = EasyExcelEnumConverter.class)
    @EasyExcel(type = GenderEnum.class)
    private Integer gender02;
}
